<template>
  <div>
    <el-button type="info" @click="increEx1">子组件调用父组件 自增Ex</el-button>
    <el-button type="info" @click="addEx1">子组件调用父组件 添加Ex</el-button>
    <el-button type="primary" @click="increEx2"
      >子组件调用父组件 事件自增Ex</el-button
    >
    <el-button type="primary" @click="addEx2"
      >子组件调用父组件 事件添加Ex</el-button
    >
    <el-button @click="clickRegular">标准子组件事件</el-button>
    <el-button type="warning" @click="increEx3"
      >子组件调用父组件 事件自增Ex</el-button
    >
  </div>
</template>
<script>
/**
 * 页面核心数据结构体说明文档
 *
 *
 */

// import New from './components/New.vue';
export default {
  name: "SecondSon",
  components: {
    // New,Old,
  },
  props: {
    sampleP: {
      type: Number,
      default: 0,
    },
    someIncreEx: {
      type: Function,
    },
  },
  data() {
    return {
      sampleD: "value",
      user: { username: "zhangsan", age: 12 },
    };
  },
  computed: {
    // sampleC() {
    //     return this.sampleD+'--';
    // }
  },
  created() {},
  mounted() {},
  methods: {
    sampleM() {},
    increEx1() {
      // this.incrementEx();
      this.$parent.incrementEx();
    },
    addEx1() {
      this.$parent.addEx("walking");
      console.log("second son 777");
    },
    increEx2() {
      this.$emit("post-incre");
      //      <second-son @post-incre="incrementEx"></second-son>
    },
    addEx2() {
      this.$emit("post-add", "thinking");
      console.log("second son");
      //      <second-son  @post-add="addEx"></second-son>
    },
    clickRegular() {
      this.$emit("post-submit", this.user, true);
    },
    increEx3() {
      this.someIncreEx && this.someIncreEx();
    },
  },
  watch: {
    // sampleC(newValue, oldValue) {
    //
    // }
  },
};
</script>

<!--<style scoped>-->
<style lang="scss" scoped></style>
